package com.friend.controller.exam;

import com.common.core.constants.HttpConstants;
import com.common.core.controller.BaseController;
import com.common.core.domain.Result;
import com.common.core.domain.TableDataInfo;
import com.friend.aspect.CheckUserStatus;
import com.friend.domain.exam.dto.ExamDTO;
import com.friend.domain.exam.dto.ExamQueryDTO;
import com.friend.service.user.UserExamService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/exam")
@Tag(name = "用户与竞赛关系管理API")
public class UserExamController extends BaseController {

    @Resource
    UserExamService userExamService;

    /**
     *竞赛报名
     *
     */
    @CheckUserStatus
    @PostMapping("/enter")
    public Result<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token, @RequestBody ExamDTO examDTO){
        return toResult(userExamService.enter(token,examDTO.getExamId()));
    }

    /**
     *获取我的竞赛列表
     *
     */
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO){
        return userExamService.list(examQueryDTO);
    }
}
